#include <graphics.h>
#include <conio.h>
#include <time.h>
void main()
{
	initgraph(640, 480);
	int i,j;
	int v_x[10],v_y[10];
	int position_x[10],position_y[10];
	for (i=0;i<10;i++)
	{
		position_x[i] = rand() % 620 + 21;
		position_y[i] = rand() % 460 +21;
		v_x[i] = 10;
		v_y[i] = 20;
	}
	BeginBatchDraw();
	while(1)
	{
		for (i=0;i<10;i++)
		{
			position_x[i] += v_x[i];
			
			if (position_x[i]>620 || position_x[i]<20)
			{
				v_x[i] = -1*v_x[i];
			}
		}
		for (i=0;i<10;i++)
		{
			position_y[i] += v_y[i];
			
			if (position_y[i]>465 || position_y[i]<20)
			{
				v_y[i] = -1*v_y[i];
			}
		}
		for (i=0;i<10;i++)
		{
			// 绘制黄线、绿色填充的圆
			setcolor(YELLOW);
			setfillcolor(GREEN);
			fillcircle(position_x[i], position_y[i], 20);
		}
		
		FlushBatchDraw();
		// 延时
		Sleep(20);
		
		for (i=0;i<10;i++)
		{
			// 绘制黑线、黑色填充的圆
			setcolor(BLACK);
			setfillcolor(BLACK);
			fillcircle(position_x[i], position_y[i], 20);
		}
	}
	EndBatchDraw();
	
	closegraph();
}